package com.example.zqm.git72.Activity;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.example.zqm.git72.Adapter.CollectionclubAdapter;
import com.example.zqm.git72.Adapter.CollectionmasterAdapter;
import com.example.zqm.git72.JavaBean.Collection;
import com.example.zqm.git72.Model.CollectionModel;
import com.example.zqm.git72.R;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class CollectMasterActivity extends AppCompatActivity {
    List<Collection> collections;
    RecyclerView recyclerView;
    String user_id;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_collectmaster);
        recyclerView = (RecyclerView) findViewById(R.id.collectmaster);
        recyclerView.setLayoutManager(new LinearLayoutManager(CollectMasterActivity.this));//设置布局
        shouData();

    }


    private void shouData() {
        //System.err.println("id =" + id);
        SharedPreferences sharedPreferences=getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        user_id=sharedPreferences.getString("user_id","");
        CollectionModel collectionModel = new CollectionModel();
        Call<List<Collection>> call = collectionModel.getListclub(user_id,"2");
        call.enqueue(new Callback<List<Collection>>() {
            @Override
            public void onResponse(Call<List<Collection>> call, Response<List<Collection>> response) {
               collections=response.body();
               recyclerView.setAdapter(new CollectionmasterAdapter(CollectMasterActivity.this, collections));//设置适配器

                //System.err.println("club course ok");
            }

            @Override
            public void onFailure(Call<List<Collection>> call, Throwable t) {

            }
        });
    }
}
